{extend name="admin@index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">订单管理</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"
               data-auth-add="{:$auth->check('order.order/add')}"
               data-auth-edit="{:$auth->check('order.order/edit')}"
               data-auth-delete="{:$auth->check('order.order/del')}"
        ></table>
    </div>
</div>
<script type="text/html" id="picTpl">
    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.nickname}}">
</script>
<!--status 1待支付 2待发货 3待收货 4已完成 5已评价 6售后退货 7已取消  pay_status 0未支付 1已支付 2已退款 is_tui 0未退 1已退-->
<script type="text/html" id="barTool">

    <a data-open='{:url("kfstatus")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('order.order/kfstatus')?'':'layui-hide'}"
       title="客服审核" data-full="true">客服审核</a>

    {{# if(d.kf_status==1&&(d.cw_status!=1)){ }}
    <a data-open='{:url("cwstatus")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('order.order/cwstatus')?'':'layui-hide'}"
       title="财务审核" data-full="true">财务审核</a>
    {{# } }}

    {{# if(d.status==1&&d.is_yc==0){ }}
    <a data-open='{:url("ycedit")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-danger {:$auth->check('order.order/ycedit')?'':'layui-hide'}"
       title="异常处理" data-full="true">异常处理</a>
    {{# } }}

    {{# if(d.is_yc==1){ }}
    <a data-open='{:url("ycedit2")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs layui-btn-danger {:$auth->check('order.order/ycedit2')?'':'layui-hide'}"
       title="异常信息" data-full="true">异常信息</a>
    {{# } }}

</script>


<!--操作模板-->

{/block}
{block name="script"}
<script>
    var selectElement = null;
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: "{:url('add')}",
            edit_url: "{:url('edit')}",
            delete_url: "{:url('del')}",
        };
        var proviec = {:json_encode($proviec)};
        table.render({
            init: init,
            autoWidth: true,
            toolbar: ['refresh',],
            url: '{:url("index")}',
            cols: [
                [
                    //预约时间 是否分派 陪诊服务 陪诊人员 会员折扣 优惠卷金额
                    // {type: 'checkbox', fixed: 'left'},
                    {field: 'id', width: '4%', title: 'ID', search: false},
                    // {field: 'order_no', align: "center", width: '18%', title: '订单编号'},

                    {field: 'sa_name', align: "center", width: '10%', title: '关联业务员'},
                    {field: 'shop_name', align: "center", width: '15%', title: '开卡店铺'},
                    // {field: 'people', align: "center", width: '10%', title: '开卡人'},
                    {field: 'phone', align: "center", width: '10%', title: '开卡手机号'},
                    {field: 'create_time', align: "center", width: '15%', title: '激活时间', search: 'range'},
                    {
                        field: 'kf_status', align: "center", width: '10%', title: '客服审核状态', templet: function (d) {
                            if (d.kf_status == 0) {
                                return '<span style="color: #00B83F">待审核</span>';
                            } else if (d.kf_status == 1) {
                                return '<span style="color: #00a0e9">已通过</span>';
                            } else if (d.kf_status == 2) {
                                return '<span style="color: red">已拒绝</span>';
                            } else {
                                return '<span>未知</span>';
                            }
                        }, selectList: {0: '待审核', 1: '已通过', 2: '已拒绝'}
                    },
                    {field: 'kf_status_time', align: "center", width: '15%', title: '客服审核时间', search: false},

                    {
                        field: 'cw_status', align: "center", width: '10%', title: '财务审核状态', templet: function (d) {
                            if (d.cw_status == 0) {
                                return '<span style="color: #00B83F">待审核</span>';
                            } else if (d.cw_status == 1) {
                                return '<span style="color: #00a0e9">已通过</span>';
                            } else if (d.cw_status == 2) {
                                return '<span style="color: red">已拒绝</span>';
                            } else {
                                return '<span>未知</span>';
                            }
                        }, selectList: {0: '待审核', 1: '已通过', 2: '已拒绝'}
                    },
                    {field: 'yc', align: "center", width: '15%', title: '异常状态',
                        selectList: {'管理单停': '管理单停', '管理停机': '管理停机', '欠费单停': '欠费单停', '欠费停机': '欠费停机', '销户': '销户', '涉诈': '涉诈', '其他': '其他'}
                        },

                    {field: 'cw_status_time', align: "center", width: '15%', title: '财务审核时间', search: false},
                    {fixed: 'right', align: 'center', width: '25%', title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        yznTable.bindevent();
        // selectElement = document.getElementById('c-province');
        // selectElement.setAttribute("lay-filter", "c-province");
        // form1();
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);

    });

    function form1() {
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(c-province)', function (data) {
                console.log(data.value);
                $.ajax({
                    type: "POST",//规定传输方式
                    url: "{:url('getc_cate')}",//提交URL
                    data: {'id': data.value},//提交的数据
                    success: function (result) {
                        if (result.code == 200) {
                            $("#c-city").empty();
                            var str = "<option value>- 全部 -</option>";
                            $.each(result.data, function (i, val) {
                                str += '<option value=' + val.id + '>' + val.name + '</option>'
                            });
                            $("#c-city").append(str);
                            layui.form.render('select');
                        }
                    },
                    error: function () {
                        alert("获取信息失败")
                    }
                });
            })
        });
    }
</script>
{/block}